<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
</html>
<?php
	session_start();
	if (!isset($_SESSION['username'])) {
		echo "<script language='javascript'>";
		echo "alert('You have no permission to read this page!');";
		echo "history.back();";
		echo "</script>";
		header("location:../login.php");
	}else {
		$uid = $_SESSION['uid'];
		require('../Controller/makefriend_controller.php');
		$senttoid = $_POST['senttoid'];
		$groupName = $_POST['groupName'];
		$selectGroup = $_POST['selectGroup'];
		if($groupName=="" && $selectGroup==""){
			$groupName="Default";
		}elseif ($groupName=="") {
			$groupName=$selectGroup;
		}else{
		}
		$control = new MakeFriend_Controller();
		$control->addFriend($uid, $senttoid, $groupName, 0);		
		header("location:./index.php?id=$senttoid");
	}
?>